package com.project.demo.game;

import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Time:19:17
 */
@Component
public class OnlineUserManager {
    //表示当前用户在游戏大厅在线状态
    private ConcurrentHashMap<Integer, WebSocketSession> gameHall = new ConcurrentHashMap<>();
    public void enterGameHall(int userId,WebSocketSession webSocketSession){
        gameHall.put(userId,webSocketSession);
    }
    public void exitGameHall(int userId){
        gameHall.remove(userId);
    }
    public WebSocketSession getFromGameHall(int userId){
        return gameHall.get(userId);
    }
}
